import random


def guess_number_game():
    # 预设一个0-9之间的整数
    answer = random.randint(0, 9)
    attempts = 0

    while True:
        # 获取用户输入
        user_guess = int(input("请输入你猜的数字（0-9）："))
        attempts += 1

        # 判断用户猜测结果
        if user_guess == answer:
            print(f"你猜了{attempts}次，猜对了，真厉害！")
            break
        elif user_guess > answer:
            print("你猜的数字大于正确答案，请再试一次。")
        else:
            print("你猜的数字小于正确答案，请再试一次。")


guess_number_game()
